from rest_framework import serializers
from shopping.models import Cart
from catalogue.serializers import FoodsSerializer
# from django.contrib.auth.models import 
from catalogue.models import Foods

class FIDSerializer(serializers.ModelSerializer):
    class Meta:
        model = Cart
        fields = ('fid')

class CartSerializer(serializers.ModelSerializer):
    # fid = FIDSerializer()
    fid = FoodsSerializer()
    class Meta:
        model = Cart
        fields = [
            'count',
            'fid',
            # 'foods',
        ]
    
    # def to_representation(self, obj):
    #     fid = data.get('fid')
    #     data = super(CartSerializer, self).to_representation(obj)
    #     data['fid'] = FoodsSerializer().data
    #     return data


    def create(self, validated_data):
        return Cart.objects.create(**validated_data)